<template>
  <div>
    <el-upload :disabled="disabled" :action="fileUrl" :on-success="handleUploadSuccess1" :file-list="fileList">
      <el-button size="small" type="primary">上传文件</el-button>
    </el-upload>
  </div>
</template>

<script>
import { getToken } from '@/util/auth';

export default {
  name: 'TuihuoUploadFIle',
  props: {
    value: {
      type: Array,
      default () {
        return []
      }
    },
    disabled: {
      type: Boolean,
      default: false
    }
  },
  data () {
    return {
      fileList: []
    };
  },
  mounted () {
    this.fileList = this.value
  },
  computed: {
    fileUrl () {
      return `/api/blade-resource/oss/endpoint/put-file?${this.website.tokenHeader}=${getToken()}`
    },
  },
  methods: {
    handleUploadSuccess1 (response, row) {
      // 处理上传成功后的响应数据
      console.log("上传成功！", response);
      // 保存返回结果到某个变量
      this.fileList.push({negativeInvoiceFile: response.data.name,name:response.data.originalName })
      this.$emit('input', this.fileList)
      console.log(row);
    },
  },
};
</script>

<style lang="scss" scoped>
</style>
